/*
*===============DdmgCloudPlatform3 V2.0===============
* DdmgCloudPlatform3 V2.0
* Copyright@大大买钢2018,All Rights Reserved
* Author: XieZhuoxun(59296309@qq.com)
* Date: 2018/8/9  08:26
* TODO: 表单验证规则，验证的rules和自定义的验证规则都放在这里面
*===============DdmgCloudPlatform3 V2.0===============
*/
// const noEmpty = (rule, value, callback) => {
//   console.log("noEmpty");
//   if (value.trim() === "") {
//     callback(new Error("不能输入空格!"));
//   } else {
//     callback();
//   }
// };

export const RULES = {
  loginRules: {
    username: [{ required: true, message: "账号不能为空", trigger: "blur" }],
    password: [{ required: true, message: "密码不能为空", trigger: "blur" }, { min: 6, max: 12, message: "密码长度在6到12个字符", trigger: "blur" }],
  },
  addMaterialRules: {
    name: [{ required: true, message: "请输入大类", trigger: "change" }],
    product_name: [{ required: true, message: "请输入产品名称", trigger: "change" }],
    material: [{ required: true, message: "请输入材质", trigger: "change" }],
    specifications: [{ required: true, message: "请输入规格", trigger: "change" }],
    origin_place: [{ required: true, message: "请输入产地", trigger: "change" }],
    coefficient: [{ required: true, validator: isNumber, trigger: "blur" }],
  },
  addBetweenUnitRules: {
    name: [{ required: true, message: "请输入公司名称", trigger: "blur" }],
    checkedList: [{ type: "array", required: true, message: "请至少选择一个客户类型" }],
    is_blacklist: [{ required: true, message: "请选择黑白名单" }],

    // account: [{ required: true, validator: isBackCard, trigger: "blur" }],
    // address: [{ required: true, message: "请输入地址", trigger: "blur" }],
    // city: [{ required: true, message: "请输入城市", trigger: "change" }],
    // areaCodeList: [{ type: "array", required: true, message: "请选择城市", trigger: "change" }],
    // founding_time: [{ required: true, message: "请输入成立时间", trigger: "change" }],
    // in_out_company: [{ required: true, message: "请输入进出口企业", trigger: "blur" }],
    // invoice_address: [{ required: true, message: "请输入开票地址", trigger: "blur" }],
    // invoice_title: [{ required: true, message: "请输入开票抬头", trigger: "blur" }],
    // nature: [{ required: true, message: "请输入性质", trigger: "change" }],
    // normal_tax: [{ required: true, message: "请输入税务正常", trigger: "blur" }],
    // open_bank: [{ required: true, message: "请输入开户银行", trigger: "blur" }],
    // phone: [{ required: true, validator: phoneNumber, trigger: "change" }],
    // province: [{ required: true, message: "请输入省份", trigger: "change" }],
    // registered_capital: [{ required: true, message: "请输入注册资金", trigger: "blur" }],
    // state: [{ required: true, message: "请输入状态", trigger: "blur" }],
    // tax_id: [{ required: true, message: "请输入税号", trigger: "blur" }],
    // type: [{ required: true, message: "请输入公司类型", trigger: "change" }],
    // invoice_phone: [{ required: true, validator: phoneNumber, trigger: "change" }],
    // business_licence: [{ required: true, message: "请上传往来单位资料", trigger: "blur" }],
  },
  addInstitutionRegRules: {
    name: [{ required: true, message: "请输入机构简称", trigger: "blur" }],
    director: [{ required: true, message: "请输入负责人", trigger: "blur" }],
    registered_capital: [{ required: true, message: "请输入注册资本", trigger: "blur" }],
    phone: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
    representative: [{ required: true, message: "请输入法人代表", trigger: "blur" }],
    duty_paragraph: [{ required: true, message: "请输入税号", trigger: "blur" }],
    deposit_bank: [{ required: true, message: "请输入开户银行", trigger: "blur" }],
    representative_identity: [{ required: true, message: "请输入法人身份证", trigger: "blur" }],
    bank_account: [{ required: true, message: "请输入账号", trigger: "blur" }],
    city: [{ required: true, message: "请选择城市", trigger: "blur" }],
    address: [{ required: true, message: "请输入地址", trigger: "blur" }],
    business_licence: [{ required: true, message: "请输入营业执照", trigger: "blur" }],

  },
  addLocationRules: {
    pid: [{ required: true, message: "请选择品名", trigger: "change" }],
    name: [{ required: true, message: "请输入产地", trigger: "blur" }],
  },
  purchaseInItemEditRuleOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "change" }],
    order_date: [{ required: true, message: "请选择单据日期", trigger: "blur" }],
    supply_unit_id: [{ required: true, message: "请选择供货单位", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择项目名称", trigger: "change" }],
    business_class: [{ required: true, message: "请选择业务类别", trigger: "change" }],
    invoice_mark: [{ required: true, message: "请选择单据性质", trigger: "change" }],
  },
  purchaseInItemEditRuleTwo: {
    order_date: [{ required: true, message: "请选择单据日期", trigger: "blur" }],
    supply_unit_id: [{ required: true, message: "请选择供货单位", trigger: "change" }],
    business_class: [{ required: true, message: "请选择业务类别", trigger: "change" }],
    invoice_mark: [{ required: true, message: "请选择单据性质", trigger: "change" }],
  },
  // 销售合同
  salesContractItemEditRuleOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    order_date: [{ required: true, message: "请选择签订日期", trigger: "blur" }],
    agreement_no: [{ required: true, message: "请输入合同编号", trigger: "change" }],
    arrivedDate: [{ required: true, message: "请选择有效期", trigger: "blur" }],
    buy_unit_id: [{ required: true, message: "请选择购货单位", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择项目名称", trigger: "change" }],
    weight: [{ required: true, message: "请输入供货重量", trigger: "change" }],
    amount: [{ required: true, message: "请输入合同金额", trigger: "change" }],
  },

  // 采购补差
  purchaseSupplementuleOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    order_date: [{ required: true, message: "请选择单据日期", trigger: "blur" }],
    supply_unit_id: [{ required: true, message: "请选择供货单位", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择项目", trigger: "change" }],
    business_type: [{ required: true, message: "请选择采购类型", trigger: "change" }],
    settlement_method: [{ required: true, message: "请选择结算方式", trigger: "change" }],
    invoice_mark: [{ required: true, message: "请选择单据性质", trigger: "submit" }],
  },
  // 销售授信
  addCreditRules: {
    business_type: [{ required: true, message: "请选择授信类型", trigger: "change" }],
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择项目", trigger: "change" }],
    fixed_amount: [{ required: true, message: "请输入固定额度", trigger: "blur" }],
  },
  // 销售定价
  saleFixedPriceRules: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    name: [{ required: true, message: "请选择名称", trigger: "change" }],
    take_effect_time: [{ required: true, message: "请输入生效时间", trigger: "blur" }],
  },
  // 现货销售验证
  spotSalesEditRuleOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "submit" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "submit" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "submit" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "submit" }],
    order_date: [{ required: true, message: "请选择单据日期", trigger: "submit" }],
    buy_unit_id: [{ required: true, message: "请选择供货单位", trigger: "submit" }],
    second_unit_id: [{ required: true, message: "请选择项目", trigger: "submit" }],
    settlement_method: [{ required: true, message: "请选择结算方式", trigger: "submit" }],
    invoice_mark: [{ required: true, message: "请选择单据性质", trigger: "submit" }],
    'transportationInfo.name': [{ required: true, message: "请输入收货人姓名", trigger: "blur" }],
    'transportationInfo.phone': [{ required: true, message: "请输入收货人电话", trigger: "blur"  }],
    'transportationInfo.transportation_contact_id': [{ required: true, message: "请选择运输联系人", trigger: "change" }],
    loadAreaCodes: [{ required: true, message: "请选择装点", trigger: "change" }],
    unLoadAreaCodes: [{ required: true, message: "请选择卸点", trigger: "change" }],
    'transportationInfo.loading_place_address': [{ required: true, message: "请输入详细地址", trigger: "blur" }],
    'transportationInfo.unloading_place_address': [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  },
  // 零购销售
  distribOfGoodsEditRuleOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "change" }],
    buy_unit_id: [{ required: true, message: "请选择购货单位", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择购方项目", trigger: "change" }],
    supply_unit_id: [{ required: true, message: "请选择供货单位", trigger: "change" }],
    supply_second_unit_id: [{ required: true, message: "请选择供方项目", trigger: "change" }],
    /*    payment_method: [{ required: true, message: "请选择付款方式", trigger: "change" }],
    payment_date: [{ required: true, message: "请选择回款日期", trigger: "blur" }],*/
    order_date: [{ required: true, message: "请选择单据日期", trigger: "blur" }],
    invoice_mark: [{ required: true, message: "请选择单据性质", trigger: "blur" }],
    'transportationInfo.name': [{ required: true, message: "请输入收货人姓名", trigger: "blur" }],
    'transportationInfo.phone': [{ required: true, message: "请输入收货人电话", trigger: "blur"  }],
    'transportationInfo.transportation_contact_id': [{ required: true, message: "请选择运输联系人", trigger: "change" }],
    loadAreaCodes: [{ required: true, message: "请选择装点", trigger: "change" }],
    unLoadAreaCodes: [{ required: true, message: "请选择卸点", trigger: "change" }],
    'transportationInfo.loading_place_address': [{ required: true, message: "请输入详细地址", trigger: "blur" }],
    'transportationInfo.unloading_place_address': [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  },
  // 销售退货申请
  saleReturnApplicationOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "change" }],
    sale_type: [{ required: true, message: "请选择退货类型", trigger: "change" }],
  },
  saleReturnApplicationSpot: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "change" }],
    sale_type: [{ required: true, message: "请选择退货类型", trigger: "change" }],
    buy_unit_id: [{ required: true, message: "请选择购货单位", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择购货项目", trigger: "change" }],
    order_date: [{ required: true, message: "请选择单据日期", trigger: "blur" }],
    payment_date: [{ required: true, message: "请选择回款日期", trigger: "blur" }],
  },
  saleReturnApplicationDis: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "change" }],
    sale_type: [{ required: true, message: "请选择退货类型", trigger: "change" }],
    buy_unit_id: [{ required: true, message: "请选择购货单位", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择购货项目", trigger: "change" }],
    supply_unit_id: [{ required: true, message: "请选择供货单位", trigger: "change" }],
    supply_second_unit_id: [{ required: true, message: "请选择供货项目", trigger: "change" }],
    order_date: [{ required: true, message: "请选择单据日期", trigger: "blur" }],
    payment_date: [{ required: true, message: "请选择回款日期", trigger: "blur" }],
  },
  // 销售补差
  saleSupplementuleOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    buy_unit_id: [{ required: true, message: "请选择购货单位", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择项目名称", trigger: "change" }],
    order_date: [{ required: true, message: "请选择单据日期", trigger: "blur" }],
    settlement_method: [{ required: true, message: "请选择结算方式", trigger: "change" }],
    supply_unit_id: [{ required: true, message: "请选择供货单位", trigger: "change" }],
  },
  purchaseInEditItemRule: {
    product_name: [{ required: true, message: "请选择品名", trigger: "change" }],
  },
  // 付款单新增&&编辑验证规则 == >paymentAddAndEdit.vue
  paymentOperationRules: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    supply_unit_id: [{ required: true, message: "请选择供货单位", trigger: "change" }],
    fund_type: [{ required: true, message: "请选择款项类别", trigger: "change" }],
    settlement_method: [{ required: true, message: "请选结算方式", trigger: "change" }],
  },
  paymentOperationRules2: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    supply_unit_id: [{ required: true, message: "请选择供货单位", trigger: "change" }],
    payment_bank_id: [{ required: true, message: "请选择付款账号", trigger: "change" }],
    fund_type: [{ required: true, message: "请选择款项类别", trigger: "change" }],
    settlement_method: [{ required: true, message: "请选结算方式", trigger: "change" }],
    payer:[{ required: true, message: "请输入付款人", trigger: "blur" }],
  },
  // 库存加工申请新增&&编辑验证规则 == >stockProcessComfirmEdit.vue
  stockProcessApplyRules: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "change" }],
    machining_type: [{ required: true, message: "请选择加工工艺", trigger: "change" }],
    fund_type: [{ required: true, message: "请选择款项类别", trigger: "change" }],
    auto_check: [{ required: true, message: "请选择是否自动验收", trigger: "change" }],
  },
  // 收款单新增&&编辑验证规则 == >receiptAddAndEdit.vue
  receiptOperationRules: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    settlement_unit_id: [{ required: true, message: "请选择结算单位", trigger: "change" }],
    fund_type: [{ required: true, message: "请选择款项类别", trigger: "change" }],
    settlement_method: [{ required: true, message: "请选择结算方式", trigger: "change" }],
  },
  receiptOperationRulesEW: {
    payee_bank_account_id: [{ required: true, message: "请选择收款账号", trigger: "change" }],
    payee_account: [{ required: true, message: "请选择收款银行", trigger: "change" }],
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    settlement_unit_id: [{ required: true, message: "请选择结算单位", trigger: "change" }],
    fund_type: [{ required: true, message: "请选择款项类别", trigger: "change" }],
    settlement_method: [{ required: true, message: "请选择结算方式", trigger: "change" }],
  },
  // 进项发票登记
  entryInvoiceRegisterRules: {
    invoice_number: [{ required: true, message: "请填写发票号码", trigger: "blur" }],
    invoice_date: [{ required: true, message: "请选择开票日期", trigger: "blur" }],
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    order_date: [{ required: true, message: "请选择登记日期", trigger: "blur" }],
    invoice_type: [{ required: true, message: "请选择发票类型", trigger: "change" }],
    settlement_unit_id: [{ required: true, message: "请选择结算单位", trigger: "change" }],
  },
  // 销项发票登记新增&&编辑验证规则 == >feeInvoiceRegisterAdd.vue
  SIROperationRules: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    business_unit_id: [{ required: true, message: "请选择业务单元", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择开票员", trigger: "change" }],
    order_date: [{ required: true, message: "请输入日期", trigger: "blur" }],
    invoice_no: [{ required: true, message: "请输入发票号码", trigger: "blur" }],
    buy_unit_id: [{ required: true, message: "请选择购货单位", trigger: "change" }],
    ticket_unit_id: [{ required: true, message: "请选择开票单位", trigger: "change" }],
    tax_id: [{ required: true, message: "请选择税号", trigger: "change" }],
    openbank: [{ required: true, message: "请选择开户行", trigger: "change" }],
    invoice_type: [{ required: true, message: "请选择发票类型", trigger: "change" }],
    /*account: [{ required: true, validator: isBackCard, trigger: "change" }],*/
    invoice_address: [{ required: true, message: "请输入开票地址", trigger: "change" }],
    phone: [{ required: true, validator: phoneNumber, trigger: "change" }],
    drawer: [{ required: true, message: "请请输入", trigger: "blur" }],
    // 销售信息
    sale_institutional_name: [{ required: true, message: "请输入销货单位", trigger: "change" }],
    sale_tax_id: [{ required: true, message: "请输入销货税号", trigger: "change" }],
    sale_openbank: [{ required: true, message: "请输入销货开户行", trigger: "change" }],
    sale_address: [{ required: true, message: "请输入销货开票地址", trigger: "change" }],
    sale_phone: [{ required: true, validator: phoneNumber, trigger: "change" }],
  },
  // 发票未开核销新增&&编辑验证规则 == >feeInvoiceRegisterAdd.vue
  invoiceUnwrittenOffEdit: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    business_unit_id: [{ required: true, message: "请选择业务单元", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择开票员", trigger: "change" }],
    order_date: [{ required: true, message: "请输入日期", trigger: "blur" }],
    invoice_no: [{ required: true, message: "请输入发票号码", trigger: "blur" }],
    buy_unit_id: [{ required: true, message: "请选择购货单位", trigger: "change" }],
    ticket_unit_id: [{ required: true, message: "请选择开票单位", trigger: "change" }],
    tax_id: [{ required: true, message: "请选择税号", trigger: "change" }],
    openbank: [{ required: true, message: "请选择开户行", trigger: "change" }],
    invoice_type: [{ required: true, message: "请选择发票类型", trigger: "change" }],
    /*account: [{ required: true, validator: isBackCard, trigger: "change" }],*/
    invoice_address: [{ required: true, message: "请输入开票地址", trigger: "change" }],
    phone: [{ required: true, validator: phoneNumber, trigger: "change" }],
    drawer: [{ required: true, message: "请请输入", trigger: "blur" }],
    // 销售信息
    sale_institutional_name: [{ required: true, message: "请输入销货单位", trigger: "change" }],
    sale_tax_id: [{ required: true, message: "请输入销货税号", trigger: "change" }],
    sale_openbank: [{ required: true, message: "请输入销货开户行", trigger: "change" }],
    sale_address: [{ required: true, message: "请输入销货开票地址", trigger: "change" }],
    sale_phone: [{ required: true, validator: phoneNumber, trigger: "change" }],
  },
  // 销项开票申请&&编辑验证规则 == >salesInvoiceApplicationOperationRules
  salesInvoiceApplicationOperationRules: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择开票人", trigger: "change" }],
    order_date: [{ required: true, message: "请输入日期", trigger: "blur" }],
    buy_unit_id: [{ required: true, message: "请选择购货单位", trigger: "change" }],
    ticket_unit_id: [{ required: true, message: "请选择开票单位", trigger: "change" }],
    account: [{ required: true, message: "请输入账号", trigger: "blur" }],
    tax_id: [{ required: true, message: "请输入税号", trigger: "blur" }],
    openbank: [{ required: true, message: "请输入开户行", trigger: "blur" }],
    invoice_type: [{ required: true, message: "请选择发票类型", trigger: "change" }],
    invoice_address: [{ required: true, message: "请输入开票地址", trigger: "change" }],
    phone: [{ required: true, validator: phoneNumber, trigger: "blur" }],
    drawer: [{ required: true, message: "请输入开户行", trigger: "blur" }],
  },

  // 零购实提验证
  deliveryGoodsEditRuleOne: {
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    order_date: [{ required: true, message: "请选择单据日期", trigger: "blur" }],
    supply_unit_id: [{ required: true, message: "请选择供货单位", trigger: "change" }],
    supply_second_unit_id: [{ required: true, message: "请选择供方项目", trigger: "change" }],
    invoice_mark: [{ required: true, message: "请选择单据性质", trigger: "change" }],
  },

  stockLossRule: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "change" }],
    order_date: [{ required: true, message: "请选择单据日期", trigger: "blur" }],
    remark: [{ required: true, message: "请输入损溢原因", trigger: "change" }],
  },
  // 销售退货验证验证规则 == 》》 saleReturnComfirmEdit.vue
  saleReturnComfirmRuleOne: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    order_date: [{ required: true, message: "请选择日期", trigger: "blur" }],
  },
  // 账户收支登记新增&&编辑验证规则 == >aieAddAndEdit.vue
  AIEOperationRule: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    inout_name: [{ required: true, message: "请选择收支名称", trigger: "change" }],
    inout_flag: [{ required: true, message: "请选择收支方向", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    settlement_method: [{ required: true, message: "请选择结算方式", trigger: "change" }],
  },
  // 费用登记验证规则 == 》》 feeRegisteruleOne
  feeRegisteruleOne: {
    order_date: [{ required: true, message: "请选择日期", trigger: "blur" }],
    cost_type: [{ required: true, message: "请选择费用类型", trigger: "change" }],
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
  },
  // 费用发票登记验证规则 == 》》 feeInvoiceRegisterRules isInvoiceNumber
  feeInvoiceRegisterRules: {
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    invoice_number: [{ required: true, validator: isInvoiceNumber, trigger: "blur" }],
    invoice_class: [{ required: true, message: "请选择发票类型", trigger: "change" }],
    settlement_unit_id: [{ required: true, message: "请选择结算单位", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择项目", trigger: "change" }],
    invoice_unit_id: [{ required: true, message: "请选择开票单位", trigger: "change" }],
  },
  // 应收调整验证规则 == 》》 accountReceivableAdjustRules
  accountReceivableAdjustRules: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    business_unit_id: [{ required: true, message: "请选择业务单元", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
  },
  // 应付调整验证规则 == 》》 APARules
  APARules: {
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    business_unit_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
  },
  // 账户转账登记验证规则 -->accountRegisterRules
  accountRegisterRules: {
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    amount: [{ required: true, message: "请输入金额", trigger: "change" }],
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择经手人", trigger: "change" }],
  },
  accountItemTableRules: {
    out_institutional_id: [{ required: true, message: "请选择转出机构", trigger: "change" }],
    in_institutional_id: [{ required: true, message: "请选择转入机构", trigger: "change" }],
    out_department_id: [{ required: true, message: "请选择转出部门", trigger: "change" }],
    in_department_id: [{ required: true, message: "请选择转入部门", trigger: "change" }],
    out_ubb_id: [{ required: true, message: "请选择转出账号", trigger: "change" }],
    in_ubb_id: [{ required: true, message: "请选择转入账号", trigger: "change" }],
  },
  // 票据转入
  billTransferInuleOne: {
    order_date: [{ required: true, message: "请选择登记日期", trigger: "blur" }],
    direction: [{ required: true, message: "请选择收付方向", trigger: "change" }],
    bill_type: [{ required: true, message: "请选择票据类型", trigger: "change" }],
    bill_no: [{ required: true, message: "请输入票据号码", trigger: "blur" }],
    endorsement_unit_id: [{ required: true, message: "请选择背书单位", trigger: "change" }],
    bill_date: [{ required: true, message: "请选择出票日期", trigger: "change" }],
    value_date: [{ required: true, message: "请选择起息日", trigger: "change" }],
    due_date: [{ required: true, message: "请选择到期日期", trigger: "change" }],
    year_discount_rate: [{ required: true, message: "请输入年贴息率", trigger: "blur" }],
    face_price: [{ required: true, message: "请输入票据面额", trigger: "blur" }],
    endorsement_price: [{ required: true, message: "请输入背书金额", trigger: "blur" }],
    discount_price: [{ required: true, message: "请输入贴息金额", trigger: "blur" }],
  },
  billTransferInuleTwo: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
  },
  billTransferOutuleOne: {
    order_date: [{ required: true, message: "请选择登记日期", trigger: "blur" }],
    direction: [{ required: true, message: "请选择收付方向", trigger: "change" }],
    bill_no: [{ required: true, message: "请输入票据号码", trigger: "change" }],
    endorsement_unit_id: [{ required: true, message: "请选择背书单位", trigger: "change" }],
    bill_date: [{ required: true, message: "请选择出票日期", trigger: "change" }],
    value_date: [{ required: true, message: "请选择起息日", trigger: "change" }],
    year_discount_rate: [{ required: true, message: "请输入年贴息率", trigger: "blur" }],
    face_price: [{ required: true, message: "请输入票据面额", trigger: "blur" }],
    endorsement_price: [{ required: true, message: "请输入背书金额", trigger: "blur" }],
    discount_price: [{ required: true, message: "请输入贴息金额", trigger: "blur" }],
  },
  billTransferOutuleTwo: {
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
  },
  stockTransferOutRuleOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "change" }],
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    out_warehouse_id: [{ required: true, message: "请选择调出仓库", trigger: "change" }],
    in_warehouse_id: [{ required: true, message: "请选择调入仓库", trigger: "change" }],
    auto_call_in: [{ required: true, message: "请选择是否自动调入", trigger: "change" }],
  },
  stockTransferInRuleOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    department_id: [{ required: true, message: "请选择部门", trigger: "change" }],
    clerk_id: [{ required: true, message: "请选择业务员", trigger: "change" }],
    warehouse_id: [{ required: true, message: "请选择仓库", trigger: "change" }],
    order_date: [{ required: true, message: "请选择日期", trigger: "change" }],
    out_warehouse_id: [{ required: true, message: "请选择调出仓库", trigger: "change" }],
    in_warehouse_id: [{ required: true, message: "请选择调入仓库", trigger: "change" }],
  },
  goldPlanRuleOne: {
    institutional_id: [{ required: true, message: "请选择登记机构", trigger: "change" }],
    projecttypes: [{ required: true, message: "请选择计划类型", trigger: "change" }],
  },
  goldApplyRules: {
    bankListId: [{ required: true, message: "请选择银行账户", trigger: "change" }],
    apply_total_amount: [{ required: true, message: "请输入申请金额", trigger: "blur" }],
  },

  // 采购发票登记
  purchaseInvoiceRegisterRules: {
    invoice_no: [{ required: true, message: "请填写发票号码", trigger: "blur" }],
    invoice_date: [{ required: true, message: "请选择开票日期", trigger: "blur" }],
    institutional_id: [{ required: true, message: "请选择机构", trigger: "change" }],
    business_unit_id: [{ required: true, message: "请选择业务单元", trigger: "change" }],
    order_date: [{ required: true, message: "请选择登记日期", trigger: "blur" }],
    invoice_type: [{ required: true, message: "请选择发票类型", trigger: "change" }],
    supply_unit_id: [{ required: true, message: "请选择结算单位", trigger: "change" }],
    second_unit_id: [{ required: true, message: "请选择项目名称", trigger: "change" }],
  },

  // 采购订单
  purchaseOrderItemEditRuleOne: {
    seller_company_id: [{ required: true, message: "请选择卖家", trigger: "change" }],
    seller_contact_name: [{ required: true, message: "请输入", trigger: "blur" }],
    seller_contact_phone: [{ required: true, message: "请输入", trigger: "blur" }],
    warehouse_name: [{ required: true, message: "请输入", trigger: "blur" }],
    contact_name: [{ required: true, message: "请输入", trigger: "blur" }],
    contact_phone: [{ required: true, message: "请输入", trigger: "blur" }],
    billing_information: [{ required: true, message: "请输入", trigger: "blur" }],
    delivery_method: [{ required: true, message: "请选择提货方式", trigger: "change" }],
    province_city_area:[{ required: true, message: "请选择代送地址", trigger: "change" }],
    address: [{ required: true, message: "请输入", trigger: "blur" }],

  },
  // 商城物资列表
  mallMaterialListRules: {
    delivery_method: [{ required: true, message: "请选择提货方式", trigger: "change" }],
    province_city_area: [{ required: true, message: "请选择省市区", trigger: "change" }],
    address: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
    pay_method: [{ required: true, message: "请选择支付方式", trigger: "change" }],
  }
};

/* 合法uri*/
export function validateURL(textval) {
  const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/;
  return urlregex.test(textval);
}

/* 小写字母*/
export function validateLowerCase(str) {
  const reg = /^[a-z]+$/;
  return reg.test(str);
}

/* 大写字母*/
export function validateUpperCase(str) {
  const reg = /^[A-Z]+$/;
  return reg.test(str);
}

/* 大小写字母*/
export function validatAlphabets(str) {
  const reg = /^[A-Za-z]+$/;
  return reg.test(str);
}

/**
 * validate email
 * @param email
 * @returns {boolean}
 */
export function validateEmail(email) {
  const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return re.test(email);
}

/*
 * 验证银行卡
 * 16~19位
 */
export function isBackCard(rule, value, callback) {
  value = String(value);
  if (value.length == 0) {
    callback(new Error("请输入银行卡"));
    // } else if (!/^(\d{16}|\d{19}|\d{23})$/.test(value)) {
    //   callback(new Error("银行卡号应该是16或19位数字"));
    // } else if (/[^0-9]/g.test(value)) {
    //   callback(new Error("银行卡号必须数字"));
    // } else {
  } else {
    callback();
  }
}
/*
 *验证手机号码
 * 国内手机以1开头
 * 11位
 */
export function phoneNumber(rule, value, callback) {
  // var value = parseInt(value);
  // if (!value) {
  //   callback(new Error("请输入手机号码"));
  // } else {
  //   var reg = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
  //   if (!reg.test(value)) {
  //     callback(new Error("请输入正确的11位手机号码"));
  //   } else {
  //     callback();
  //   }
  // }
  // 因为需求未知，暂时先验证长度
  let phoneNum = value.toString();
  if (!phoneNum) {
    callback(new Error("请输入联系电话"));
    // } else {
    //   if (8 > phoneNum.length || phoneNum.length > 12) {
    //     callback(new Error("请输入正确的联系电话"));
    //   } else {
    //     callback();
    //   }
  } else {
    callback();
  }
}
/*
 *身份证验证
 * 15~18位
 */
export function isCrad(rule, value, callback) {
  // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X (现在只验证18位)
  //	var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;

  if (!value) {
    callback(new Error("请输入身份证号"));
  } else {
    var reg = /(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    if (!reg.test(value)) {
      callback(new Error("请输入正确的18位身份证号码"));
    } else {
      callback();
    }
  }
}

/*
 *验证税号
 */
export function taxNumber(rule, value, callback) {
  value = String(value);
  if (value.length == 0) {
    callback(new Error("请输入税号"));
  } else if (/[^0-9a-zA-Z]/g.test(value)) {
    callback(new Error("税号格式不符"));
  } else {
    callback();
  }
}

/*
 *非空验证数字
 */
export function isNumber(rule, value, callback) {
  value = String(value);
  if (value.length == 0) {
    callback(new Error("该项不能为空"));
  } else if (value.match(/^(\d*)(\.?)(\d+)$/g) == null) {
    callback(new Error("该项必须为数字"));
  } else {
    callback();
  }
}

/*
 * 数据权限分配·弹框
 * 验证用户选择项
 */
export function isuUserItem(rule, value, callback) {
  if (value.length == 0) {
    callback(new Error("请选择用户"));
  } else {
    callback();
  }
}

/*
 * 数据权限分配·弹框
 * 验证数据角色项
 */
export function isuRoleItem(rule, value, callback) {
  if (value.length == 0) {
    callback(new Error("请选择数据角色"));
  } else {
    callback();
  }
}

/*
 * 采购价格调整
 * 验证整数，小数，+-数字
 */
export function isParseFloat(rule, value, callback) {
  if (!value) {
    callback(new Error("请输入数字或正数或负数"));
  } else {
    let reg = /^(-?(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/;
    if (!reg.test(value)) {
      callback(new Error("请输入数字或正数或负数"));
    } else {
      callback();
    }
  }
}

/*
* /[0-9a-zA-Z]$/
* 验证字母数字
*
**/

export function isInvoiceNumber(rule, value, callback) {
  if (!value) {
    callback(new Error("请输入发票号码"));
  } else {
    let reg = /[0-9a-zA-Z]$/;
    if (!reg.test(value)) {
      callback(new Error("请输入数字或字母"));
    } else {
      callback();
    }
  }
}
